package display.testcase;
/**
 * @author Sachin
 * This class is used to test the test cases which is basically intends to read the specfied file .
 */
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import dbmanager.DBManager;
import display.WriteTOTextFile;
import junit.framework.TestCase;

public class testWriteToTextFile extends TestCase {
	 public testWriteToTextFile(String name)
	 {
		 super(name);
	 }
	 /**
	  * test535File()  This method is used to read the contents of specfied file ie 535_mail.txt and rreflects the changes as per our modification
	  * @throws IOException
	  */
	 public void test535File() throws IOException
	 {
		String Sourcepath="//home//Sachin//Desktop//FileFor TestCase//";
		String Targetpath="//home//Sachin//Desktop//FileFor TestCase//535_mail.txt";
		DBManager db = new DBManager();	
		db.getConnect();
		WriteTOTextFile wtf = new WriteTOTextFile(Sourcepath,db);
		StringBuffer input =new StringBuffer(Sourcepath);
		wtf.WriteToTextFile("535");
		RandomAccessFile fread = null;
		try 
		{
			fread = new RandomAccessFile(Targetpath,"r");
		} 
		catch (Exception e) {
		}
	  String actual[]={"",
        		"                         SACHIN111",
"                       WIKI CONCEPT",
"           234/235, LAXMI COLONY SOLAPUR ROAD HADAPSAR PUNE 411028",
"-----------------------------------------------------------------------",
" PO NO         535 RUPEES AND  PAISA ONLY535",
"------------------------------------------------------------------------",
" ORDERDATE     TWENTYSIX THOUSAND FOUR HUNDRED  RUPEES AND  PAISA ONLY2007-12-21 18:30:452007-12-21 18:30:45",
" TO             SAMRUDDHI GEN. STORESAMRUDDHI GEN. STORE",
" ADDR           PUNE MAHARASHTRAAMRUTA NAGAR ",
"-----------------------------------------------------------------------"};
        String line;
		int j=0;
		while((line=fread.readLine())!=null)	
		{		
			System.out.println(line);
			System.out.println(actual[j]);
		assertEquals(line, actual[j]);
		j++;
		}
	 }
	 /**
	  * test536File()  This method is used to read the contents of specfied file ie 536_mail.txt and rreflects the changes as per our modification
	  * @throws IOException
	  */
	 public void test536File() throws IOException
	 {
		String Sourcepath="//home//Sachin//Desktop//FileFor TestCase//";
		String Targetpath="//home//Sachin//Desktop//FileFor TestCase//536_mail.txt";
		DBManager db = new DBManager();	
		db.getConnect();
		WriteTOTextFile wtf = new WriteTOTextFile(Sourcepath,db);
		StringBuffer input =new StringBuffer(Sourcepath);
		wtf.WriteToTextFile("536");
		RandomAccessFile fread = null;
		try 
		{
			fread = new RandomAccessFile(Targetpath,"r");
		} 
		catch (Exception e) {
		}
	  String actual[]={"                                         INFORMATION",
"                                        WIKIOCEAN",
"     HOME       ABOUTUS    CONTACTUS",
"",
"",
" EID            22",
" ENAME          SACHIN KURDUKAR",
" REF            HEMANT ",
" EADDR          LAXMI COLONY HADAPSAR",
" DESGNATION     SOFTWARE ENGG",
" MOBILENO       9372003381",
" QUALIFICATION  BE(IT)-CDAC",
" SKIIL SET      JAVA,J2EE,EJB,STRUTS,ORACLE",
"",
"",
"",
" DATE:31/12/2007                                             PLACE:PUNE",
"",
"",
"",
"                                        WEB:HTTP://WWW.WIKIOCEAN.NET"};
        String line;
		int j=0;
		while((line=fread.readLine())!=null)	
		{		
			System.out.println(line);
			System.out.println(actual[j]);
		assertEquals(line, actual[j]);
		j++;
		}
	
	 }
	 /**
	  * test537BlankFile()  This method is used to read the contents of specfied file ie 537_mail.txt and rreflects the changes as per our modification
	  * @throws IOException
	  */
	 public void test537BlankFile() throws IOException
	 {
		String Sourcepath="//home//Sachin//Desktop//FileFor TestCase//";
		String Targetpath="//home//Sachin//Desktop//FileFor TestCase//537_mail.txt";
		DBManager db = new DBManager();	
		db.getConnect();
		WriteTOTextFile wtf = new WriteTOTextFile(Sourcepath,db);
		StringBuffer input =new StringBuffer(Sourcepath);
		wtf.WriteToTextFile("537");
		RandomAccessFile fread = null;
		try 
		{
			fread = new RandomAccessFile(Targetpath,"r");
		} 
		catch (Exception e) {
		}
	  String actual[]={" "};
        String line;
		int j=0;
		while((line=fread.readLine())!=null)	
		{		
			System.out.println(line);
			System.out.println(actual[j]);
		assertEquals(line, actual[j]);
		j++;
		}
	
	 }
	 /**
	  *test538SpecialCharFile()  This method is used to read the contents of specfied file ie 538_mail.txt and rreflects the changes as per our modification
	  * @throws IOException
	  */
	 public void test538SpecialCharFile() throws IOException
	 {
		String Sourcepath="//home//Sachin//Desktop//FileFor TestCase//";
		String Targetpath="//home//Sachin//Desktop//FileFor TestCase//538_mail.txt";
		DBManager db = new DBManager();	
		db.getConnect();
		WriteTOTextFile wtf = new WriteTOTextFile(Sourcepath,db);
		StringBuffer input =new StringBuffer(Sourcepath);
		wtf.WriteToTextFile("538");
		RandomAccessFile fread = null;
		try 
		{
			fread = new RandomAccessFile(Targetpath,"r");
		} 
		catch (Exception e) {
		}
	  String actual[]={"",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "          ########################################################",
			  "          **                                                    **",
			  "          **                                                    **",
			  "          **           WELCOME TO WIKI OCEAN                     **",
			  "          **                                                    **",
			  "          |||||||||||||||||||||||||||||||||||||||||||||||||||||||||"};
			  
	 
			  
	    String line;
		int j=0;
		while((line=fread.readLine())!=null)	
		{		
			System.out.println(line);
			System.out.println(actual[j]);
		assertEquals(line, actual[j]);
		j++;
		}
	
	 }
	 /**
	  *test539NumericFile()  This method is used to read the contents of specfied file ie 538_mail.txt and rreflects the changes as per our modification
	  * @throws IOException
	  */
	 public void test539NumericFile() throws IOException
	 {
		String Sourcepath="//home//Sachin//Desktop//FileFor TestCase//";
		String Targetpath="//home//Sachin//Desktop//FileFor TestCase//539_mail.txt";
		DBManager db = new DBManager();	
		db.getConnect();
		WriteTOTextFile wtf = new WriteTOTextFile(Sourcepath,db);
		StringBuffer input =new StringBuffer(Sourcepath);
		wtf.WriteToTextFile("539");
		RandomAccessFile fread = null;
		try 
		{
			fread = new RandomAccessFile(Targetpath,"r");
		} 
		catch (Exception e) {
		}
	  String actual[]={"",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "",
			  "            1111111111111111111111111111111111111111111111111",
			  "             22222222222222222222222102222222222222222222222222",
			  "             44444444444444444444444444444444444444444444444444"};
			  
	    String line;
		int j=0;
		while((line=fread.readLine())!=null)	
		{		
			System.out.println(line);
			System.out.println(actual[j]);
		assertEquals(line, actual[j]);
		j++;
		}
	
	 }
	 
	 
}	
	 
